
* Code to reproduce “Table II. Uncorrelated longitudinal TPM for the effect of local spending on organized crime violence (1995-2015)”, using the integrated “Dez_and_Death_integrated_dataset.dta”
xtset code year

*drop those years for which no sufficient data are available
keep if year==1990 | year ==1995 | year ==2000 | year==2005| year==2010| year ==2015

*interpolation of important variables for which large amounts of missing values exist 
by code: ipolate Indigenous_Pop_Share year, gen(Indig_Share_Ipol) epolate
by code: ipolate Share_Head_of_HH_Female year, gen(Share_Female_HH_ipol) epolate
by code: ipolate Household_Size year, gen( Household_Size_Ipol ) epolate
by code: ipolate HDI_Services year, gen( HDI_Services_Ipol ) epolate

*Generate dummy variables for years and states
tabulate year, gen(year)
rename year1 y1990
rename year2 y1995
rename year3 y2000
rename year4 y2005
rename year5 y2010
rename year6 y2015
tabulate Estado_ID, gen(Estado)
xtset code year

* Computation of the binary part of the “Uncorrelated longitudinal TPM for the effect of local spending on organized crime violence (1995-2015)”
xtlogit participation_hom mn_Spending_Cap_Real_Munic dev_Spending_Cap_Real_Munic   mn_Own_Revenue_Share dev_Own_Revenue_Share  HDI_Services_Ipol Share_Female_HH_ipol Household_Size_Ipol Population_Density Population_15_29_Males  Males_Per_100_Females Indig_Share_Ipol Population Munic_Size_Categ Laakso_Tag_Ind Dummy_Border_PCoast y2000-y2015 Estado1-Estado32, re or

*Results and important additional parameters are stored in an excel file
putexcel set "results_hyb_panel9515.xlsx", sheet("Logit_9515") modify
putexcel I3=("Number of obs")
putexcel J3=(e(N))
putexcel I4=("Number of groups")
putexcel J4=(e(N_g))
putexcel I5=(" Wald_Chi2")
putexcel J5=(e(chi2))
matrix a = r(table)'
matrix a = a[., 1..6]
putexcel A2=matrix(a)


* Computation of the continuous part of the uncorrelated longitudinal TPM for the effect of local spending on organized crime violence (1995-2015)”
xtreg Homicides_All_Cap_Pos_Log mn_Spending_Cap_Real_Munic dev_Spending_Cap_Real_Munic   mn_Own_Revenue_Share dev_Own_Revenue_Share  HDI_Services_Ipol Share_Female_HH_ipol Household_Size_Ipol Population_Density Population_15_29_Males  Males_Per_100_Females Indig_Share_Ipol Population Munic_Size_Categ Laakso_Tag_Ind Dummy_Border_PCoast y2000-y2015 Estado1-Estado32, re robust

*Results and important additional parameters are stored in an excel file
putexcel set "results_hyb_panel9515.xlsx", sheet("Linear_9515") modify
putexcel I3=("Number of obs")
putexcel J3=(e(N))
putexcel I4=("Number of groups")
putexcel J4=(e(N_g))
putexcel I5=("Wald_Chi2")
putexcel J5=(e(chi2))
putexcel I6=("R2")
putexcel J6= (e(r2_o))
matrix a = r(table)'
matrix a = a[., 1..6]
putexcel A2=matrix(a)
